//
//  NewLike.m
//  Socrates
//
//  Created by shy on 15/4/17.
//  Copyright (c) 2015年 shy. All rights reserved.
//

#import "NewCommentViewController.h"

#import "NotificationCell.h"
#import "RDVTabBarController.h"
#import "CircleImage.h"

typedef enum {
    kNotification_comment_item = 0,
    kNotification_attention_item,
    kNotification_compliment_item,
    kNotification_invitation_item,
    kNotification_appraise_item,
    kNotification_Num,
} LimitationItems;

static const int kLimitationRowHeight = 60;

@implementation NewCommentViewController

- (void) viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor colorWithRed:239/255. green:239/255. blue:244/255. alpha:1.];
    self.navigationController.navigationBar.hidden = NO;
    [self.tableView registerNib:[UINib nibWithNibName:@"NotificationCell" bundle:nil] forCellReuseIdentifier:@"NotificationCellIdentifier"];
    self.tableView.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0);
    self.tableView.separatorColor = [UIColor lightGrayColor];
    self.tableView.tableFooterView = [[UIView alloc] init];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return kLimitationRowHeight;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return kNotification_Num;
}

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
    // Remove seperator inset
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
        [cell setSeparatorInset:UIEdgeInsetsZero];
    }
    
    // Prevent the cell from inheriting the Table View's margin settings
    if ([cell respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]) {
        [cell setPreservesSuperviewLayoutMargins:NO];
    }
    
    // Explictly set your cell's layout margins
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }
}

- (NotificationCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    NotificationCell *cell = [tableView dequeueReusableCellWithIdentifier:@"NotificationCellIdentifier"];
    UIView *selectView = [[UIView alloc] init];
    selectView.backgroundColor = [UIColor lightGrayColor];
    cell.selectedBackgroundView = selectView;
    
    UIImage *userImage = [CircleImage circleImageWithName:@"angela_test" borderWidth:0 borderColor:[UIColor clearColor]];
    [cell.notificationImage setImage:userImage];
    
    switch ([indexPath row]) {
        case kNotification_comment_item:
//            [cell.notificationImage setImage:[UIImage imageNamed:@"notification_comment"]];
            cell.notificationType.text = @"您发布的活动有新评论";
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            break;
        case kNotification_attention_item:
//            [cell.notificationImage setImage:[UIImage imageNamed:@"notification_attention"]];
            cell.notificationType.text = @"新的关注者";
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            break;
        case kNotification_compliment_item:
//            [cell.notificationImage setImage:[UIImage imageNamed:@"notification_compliment"]];
            cell.notificationType.text = @"有人赞了你的活动";
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            break;
        case kNotification_invitation_item:
//            [cell.notificationImage setImage:[UIImage imageNamed:@"notification_invitation"]];
            cell.notificationType.text = @"有人邀请你参加活动";
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            break;
        case kNotification_appraise_item:
//            [cell.notificationImage setImage:[UIImage imageNamed:@"notification_appraise"]];
            cell.notificationType.text = @"请及时评价活动";
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            break;
        default:
            break;
    }
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
    [[self rdv_tabBarController] setTabBarHidden:YES animated:YES];
}

- (void)viewWillDisappear:(BOOL)animated {
    [[self rdv_tabBarController] setTabBarHidden:NO animated:YES];
    
    [super viewWillDisappear:animated];
}

@end
